<template>
  <div>
    <el-container>
      <!--搜索开始-->
      <el-header class="head1">
        <span><h2>订酒店</h2></span>
        <el-row style="margin-top: 40px" :gutter="20">
          <el-col :span="7">
            <div class="grid-content bg-purple">
              <el-input
                  placeholder="出行目的地"
                  v-model="searchContent"
              >
              </el-input>
            </div>
          </el-col>
          <el-col :span="5">
            <div class="grid-content bg-purple">
              <el-input
                  placeholder="入住日期"
                  suffix-icon="el-icon-date"
                  v-model="liveDate"
              >
              </el-input>
            </div>
          </el-col>
          <el-col :span="5">
            <div class="grid-content bg-purple">
              <el-input
                  placeholder="离店日期"
                  suffix-icon="el-icon-date"
                  v-model="goDate"
              >
              </el-input>
            </div>
          </el-col>
          <el-col :span="5">
            <div class="grid-content bg-purple">
              <el-input
                  placeholder="人数未定"
                  suffix-icon="el-icon-user"
                  v-model="people"
              >
              </el-input>
            </div>
          </el-col>
          <el-button style="background-color: #FFA902FF;border: 0px" type="primary"
                     icon="el-icon-search"
                     @click="searchInformation(searchContent)"
          ></el-button>
        </el-row>
      </el-header>
      <!--搜索结束-->
      <!--中间部分开始-->
      <!--图片文字开始-->
      <div style="margin-top: 100px;padding-left: 0px;width: 950px">
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <i style="font-size: 60px;float: left" class="el-icon-collection"></i>
              <div style="display: inline-block">
                <h2>住宿攻略</h2>
                <span class="span-s">区域攻略到特色主题，应有尽有</span>
              </div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <i style="font-size: 60px;float: left" class="el-icon-shopping-bag-1"></i>
              <div style="display: inline-block">
                <h2>专享价格</h2>
                <span class="span-s">多平台价格对比，天天专享特惠</span>
              </div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <i style="font-size: 60px;float: left" class="el-icon-user"></i>
              <div style="display: inline-block">
                <h2>真实点评</h2>
                <span class="span-s">超过100万真实用户点评和游记</span>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
      <!--图片文字结束-->
      <!--主题住宿开始-->
      <template>
        <div class="hotel-live">
          <h2>主题住宿</h2>
        </div>
        <!--图片展示1开始-->
        <el-tabs class="el-tabs-s" v-model="activeName1" @tab-click="handleClick" stretch>
          <el-tab-pane label="浪漫花海" name="浪漫花海">
            <el-row :gutter="20">
              <el-col :span="8" :key="item.id" v-for="item in themeArr">
                <div @click="p(item.location)" class="img-s">
                  <el-image
                      style="width: 100%; height: 100%"
                      :src="serveUrl+item.url"
                      fit="fill"></el-image>
                  <span class="span-text">{{item.location}}</span>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="周日好住处" name="周日好住处">
            <el-row :gutter="20">
              <el-col :span="8" :key="item.id" v-for="item in themeArr">
                <div @click="p(item.location)" class="img-s">
                  <el-image
                      style="width: 100%; height: 100%"
                      :src="serveUrl+item.url"
                      fit="fill"></el-image>
                  <span class="span-text">{{item.location}}</span>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="高山流水" name="高山流水">
            <el-row :gutter="20">
              <el-col :span="8" :key="item.id" v-for="item in themeArr">
                <div @click="p(item.location)" class="img-s">
                  <el-image
                      style="width: 100%; height: 100%"
                      :src="serveUrl+item.url"
                      fit="fill"></el-image>
                  <span class="span-text">{{item.location}}</span>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="中华古风" name="中华古风">
            <el-row :gutter="20">
              <el-col :span="8" :key="item.id" v-for="item in themeArr">
                <div @click="p(item.location)" class="img-s">
                  <el-image
                      style="width: 100%; height: 100%"
                      :src="serveUrl+item.url"
                      fit="fill"></el-image>
                  <span class="span-text">{{item.location}}</span>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
        <!--图片展示1结束-->
      </template>
      <!--主题住宿结束-->
      <!--特价酒店开始-->
      <template>
        <div class="hotel-live" style="margin-top: 100px">
          <h2>特价酒店</h2>
        </div>
        <!--图片展示2开始-->
        <el-tabs class="el-tabs-s" v-model="activeName2" @tab-click="hotelClick" stretch>
          <el-tab-pane label="香港" name="香港">
            <el-row :gutter="20">
              <el-col :span="8" :key="item.id" v-for="item in hotelArr">
                <div @click="searchHotelInfo(item.id)" class="img-s">
                  <el-image
                      style="width: 100%; height: 100%"
                      :src="serveUrl+item.url"
                      fit="fill"></el-image>
                  <span class="span-hotel">{{item.name}}</span>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="北京" name="北京">
            <el-row :gutter="20">
              <el-col :span="8" :key="item.id" v-for="item in hotelArr">
                <div @click="searchHotelInfo(item.id)" class="img-s">
                  <el-image
                      style="width: 100%; height: 100%"
                      :src="serveUrl+item.url"
                      fit="fill"></el-image>
                  <span class="span-hotel">{{item.name}}</span>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="厦门" name="厦门">
            <el-row :gutter="20">
              <el-col :span="8" :key="item.id" v-for="item in hotelArr">
                <div @click="searchHotelInfo(item.id)" class="img-s">
                  <el-image
                      style="width: 100%; height: 100%"
                      :src="serveUrl+item.url"
                      fit="fill"></el-image>
                  <span class="span-hotel">{{item.name}}</span>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="澳门" name="澳门">
            <el-row :gutter="20">
              <el-col :span="8" :key="item.id" v-for="item in hotelArr">
                <div @click="searchHotelInfo(item.id)" class="img-s">
                  <el-image
                      style="width: 100%; height: 100%"
                      :src="serveUrl+item.url"
                      fit="fill"></el-image>
                  <span class="span-hotel">{{item.name}}</span>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
        <!--图片展示2结束-->
      </template>
      <!--特价酒店结束-->
    </el-container>
  </div>
</template>

<script>
export default {
  data(){
    return{
      searchContent:'',
      activeIndex: '1',
      activeName1: '浪漫花海',
      activeName2:'香港',
      isLogin:false,
      liveDate:'',
      goDate:'',
      people:'',
      user:{},
      currentUser:{},
      themeArr:[],
      hotelArr:[],
      serveUrl:'http://localhost:9580'
    }
  },
  methods:{
    searchHotelInfo(id){
      this.$router.push('/page/book/BookHotel-HotelInfo');
      console.log(id);
      localStorage.setItem('hotelId',id);
    },
    p(location){
      this.$router.push('/page/book/BookHotel-Theme');
      let str=location.slice(2,4)
      console.log(str);
      localStorage.setItem('searchContent',str);
    },
    searchInformation(inputText){
      this.$router.push('/page/book/BookHotel-Theme');
      localStorage.setItem('searchContent',inputText);
      console.log(inputText);
    },
    handleClick(tab, event) {
      this.loadThemeImgList();
      console.log(this.activeName1);
    },
    hotelClick(tab, event) {
      this.loadHotelImgList();
      console.log(this.activeName2);
    },
    loadThemeImgList(){
      let url = 'http://localhost:9580/themes/user/getThemeImgListByThemeNameSelectId?themeName='+this.activeName1;

     /* let formData=this.qs.stringify(this.activeName1.name);*/
      this.axios
          .create({'headers': {'Authorization': localStorage.getItem('jwt')}})
          .get(url).then((response) => {
        let responseBody = response.data;
        this.themeArr=responseBody.data;
        console.log(this.themeArr);
      });
    },
    loadHotelImgList(){
      let url = 'http://localhost:9580/hotels/user/getHotelListBySomethingOfLocation?location='+this.activeName2;

     /* let formData=this.qs.stringify(this.activeName1.name);*/
      this.axios
          .create({'headers': {'Authorization': localStorage.getItem('jwt')}})
          .get(url).then((response) => {
        let responseBody = response.data;
        this.hotelArr=responseBody.data;
        console.log(this.hotelArr);
      });
    }
  },
  mounted() {
    this.loadThemeImgList();
    this.loadHotelImgList();
  }
}
</script>

<style>
.head {
  color: #333;
  text-align: center;
  line-height: 60px;
  box-sizing: border-box;
}

.head1 {
  margin-top: 100px;
  padding-left: 0px;
  width: 950px;
}

.el-main {
  color: #333;
  height: 100%;
  padding-left: 450px;
  box-sizing: border-box;
}

.el-menu-demo {
  width: 100%;
  margin: 0 auto;
  padding-left: 350px;
  box-sizing: border-box;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
}

.head-r-l a {
  text-decoration: none;
}

.el-row {
  margin-bottom: 20px;
}

:last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {

}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

h2 {
  margin: 0;
  font-size: 20px;
}

.span-s {
  font-size: 15px;
}

.hotel-live {
  text-align: center;
  width: 950px;
  margin-top: 50px;
}

.el-tabs-s {
  width: 950px;
  box-sizing: border-box;
}

.monitorTop {
  /*!/ position: relative;  相对定位,*/
  position: relative;
  /*vw是width of view(port)的缩写；
100vw表示百分之百的视图宽度；
123px是需要减去的宽度；
减号的两边必须都有至少一个空格*/
  height: calc(50% - 123px);
}

.monitorTop .el-tabs__item {
  font-size: 20px !important;
}

::v-deep .el-tabs__nav-scroll {
  width: 50%;
  margin: 0 auto
}
.img-s{
  width: 303px;
  height: 220px;
  margin-bottom: 15px;
  cursor: pointer;
}
.foot-s{
  background-color: #3e3e3e;
  height: 300px;
  text-align: center;
  color: #bbbbbb;
}
.b1{
  height: 60px;
  font-size: 15px;
}
.span-text{
  z-index: 3;
  position: relative;
  color: white;
  font-size: 25px;
  top: -125px;
  left: 110px;
}
.span-hotel{
  z-index: 3;
  position: relative;
  color: white;
  font-size: 15px;
  top: -35px;
  left: 10px;
}
</style>